## 指定最低版本
cmake_minimum_required(VERSION 2.8)

## 宏
set(PROJECT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/..)

cmake_policy(SET CMP0046 NEW)

## 为当前路径以及子目录的源文件加入由-D预编译定义
## add_definitions(-DFOO -DDEBUG ...)

## 输出路径
set(OUTPUT_PATH            ${PROJECT_PATH}/Out)
set(LIBRARY_OUTPUT_PATH    ${OUTPUT_PATH}/lib)
set(EXECUTABLE_OUTPUT_PATH ${OUTPUT_PATH}/bin)

## 库路径
link_directories(${OUTPUT_PATH}/lib)

## led includes src
include_directories (${PROJECT_PATH}/Ipc)
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/Led)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Led SRC_LIB_LED)

## libled.so
add_library(libled SHARED ${SRC_LIB_LED})
set_target_properties(libled PROPERTIES OUTPUT_NAME "led")
set_target_properties(libled PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(libled c libipc pthread stdc++)

## api includes src
include_directories (${PROJECT_PATH}/Ipc)
include_directories (${PROJECT_PATH}/Server/Api)
aux_source_directory(${PROJECT_PATH}/Server/Api SRC_LIB_API)

## libled_api.so
add_library(libledapi SHARED ${SRC_LIB_API})
set_target_properties(libledapi PROPERTIES OUTPUT_NAME "ledapi")
set_target_properties(libledapi PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(libledapi c libipc pthread stdc++)

## main_server.exe
set(SRC_BIN_SERVER  main_server.cc)
add_executable       (main_server ${SRC_BIN_SERVER})
set_target_properties(main_server PROPERTIES OUTPUT_NAME "mainserver")
target_link_libraries(main_server c libipc pthread led)
add_dependencies     (main_server libipc libled)


